import lejos.nxt.ADSensorPort;
import lejos.nxt.ColorSensor;
import lejos.nxt.LightSensor;
import lejos.nxt.SensorPort;
import lejos.robotics.Color;


public class LejosLightSensor {

	private static LightSensor      ls = new LightSensor(SensorPort.S1);
	private static int  LightLEVEL  =  400;
	
	public static void setLSSensorPort(ADSensorPort port){
		ls = new LightSensor(port);
	}
	
	/*Signaux autorisés:
	 * LIGHT, LIGHTOff, LIGHTOn, GetLIGHTLevel
	 * LIGHTOverTaking, LIGHTValue
	 * 
	 * valués:
	 * SetLIGHTLevel
	 * */
	
		
	public static int inputLIGHT(){
		return ls.readNormalizedValue();
	}
	
	
	public static int inputGETLIGHTTLEVEL(){
		return LightLEVEL ;
	}
	
	public static int inputLIGHTVALUE(){
		return ls.getLightValue();
	}
	
	public static boolean  inputLIGHTOverTaking(){		
		if (ls.readNormalizedValue() > LightLEVEL) {                           
			    return true;                   
		}  
		return false;
	}
		
	
	public static void outputSETLIGHTLEVEL(int level){
		LightLEVEL = level;
	}

	public static void outputLIGHTOFF(){
		ls.setFloodlight(false);
	}
	
	public static void outputLIGHTON(){
		ls.setFloodlight(Color.GREEN);
		ls.setFloodlight(true);
	}
}
